package top.pengdong.pictureShare.tweet.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import top.pengdong.pictureShare.common.model.PageUtils;
import top.pengdong.pictureShare.common.model.R;
import top.pengdong.pictureShare.tweet.entity.PsLabelEntity;
import top.pengdong.pictureShare.tweet.service.PsLabelService;


/**
 * 分类表单
 *
 * @author chenshun
 * @email pengshi12138@outlook.com
 * @date 2022-05-08 11:26:09
 */
@RestController
@RequestMapping("api/label")
public class PsLabelController {
    @Autowired
    private PsLabelService psLabelService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = psLabelService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 列表
     */
    @RequestMapping("/all_list")
    public R list(){
        List page = psLabelService.list();

        return R.ok().put("result", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		PsLabelEntity psLabel = psLabelService.getById(id);

        return R.ok().put("psLabel", psLabel);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody PsLabelEntity psLabel){
		psLabelService.save(psLabel);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody PsLabelEntity psLabel){
		psLabelService.updateById(psLabel);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		psLabelService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
